package com.example.javabasic.shejimoshi.celve.demo2;

import java.util.HashMap;
import java.util.Map;

//策略工厂
public class StrategyFactory {
    private static final Map<String,Strategy> map = new HashMap();


    public static  void set(String key,Strategy strategy){
        synchronized (map){
            map.put(key,strategy);
        }
    }


    public static  Strategy get(String key){
        synchronized(map){
            return map.get(key);
        }
    }

    public static void strategyMethod(String key){
        map.get(key).strategyMethod();
    }
}
